Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale tablet output size when UI Scaling mode is "Everything" #31141

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DanielPower
Copy link
Contributor

@DanielPower DanielPower commented Dec 16, 2024

Fixes #12098

Keeping this as a draft until ppy/osu-framework#6460 merges.

Description

Based on discussions in the issue, scaling tablet output when UI Scaling mode is set to "Everything" will address the needs of full area tablet players who use screen scaling. With this PR, tablet output will not scale when UI Scaling is set to "Gameplay Only" or "Exclude Overlays" since this results in elements being non-interactable with the tablet, which may or may not be desirable for some users and requires further discussion.

Demonstration

untitled.mp4

In the first half of the video I demonstrate how on the current lazer client, when the UI is scaled the tablet area is still mapped to the entire window. This results in a significant portion of the tablet area becoming unusable during gameplay.

In the second half of the video, I demonstrate how on this branch, when the UI is scaled the tablet area is mapped only to the scaled portion of the game window. This means the full tablet area can be used for gameplay.

Manual Testing

Initial game launch with no configuration (deleted osu-development folder)
Game initialized with ScalingMode=Off, and tablet set to full area as expected

Set ScaleMode=Everything

  • Modifed scale
  • Modified position
  • Resized game window
  • Tested in Windowed, Borderless, and Fullscreen

Tablet area appropriately mapped to only the scaled area

All other ScaleMode values
Tablet area appropriately mapped to the full screen.

Automated testing

Testing this might require mocking tablet input in order to ensure the cursor position is correct for the given layout configuration. But I don't see any examples of this in other tests. I'm open to suggestions on how best to introduce automated testing for this feature, as I'm not familiar enough with the existing testing practices.

Dependencies

Depends on osu-framework changes: ppy/osu-framework#6460

@DanielPower DanielPower marked this pull request as ready for review December 17, 2024 02:12
@DanielPower DanielPower marked this pull request as draft December 17, 2024 02:34
@timschumi
Copy link
Contributor

timschumi commented Dec 24, 2024

As a side note, I can't immediately tell from the diff here since I'm not very familiar with the code, but the "conform to current game aspect ratio" button might also need adjustments to use the correct aspect ratio.

While trying to tackle the problem myself a few days ago, I solved it like this:

diff --git a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs
index 00ffbc1120..ae0c24cad6 100644
--- a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs
+++ b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs
@@ -154,7 +154,19 @@ private void load(OsuColour colours, LocalisationManager localisation)
                             Text = TabletSettingsStrings.ConformToCurrentGameAspectRatio,
                             Action = () =>
                             {
-                                forceAspectRatio((float)host.Window.ClientSize.Width / host.Window.ClientSize.Height);
+                                float clientWidth = host.Window.ClientSize.Width;
+                                float clientHeight = host.Window.ClientSize.Height;
+
+                                if (config.Get<ScalingMode>(OsuSetting.Scaling) == ScalingMode.Everything)
+                                {
+                                    float sizeX = config.Get<float>(OsuSetting.ScalingSizeX);
+                                    float sizeY = config.Get<float>(OsuSetting.ScalingSizeY);
+
+                                    clientWidth *= sizeX;
+                                    clientHeight *= sizeY;
+                                }
+
+                                forceAspectRatio(clientWidth / clientHeight);
                             },
                             CanBeShown = { BindTarget = enabled }
                         },

Granted, with the new bindables we can probably significantly reduce this to the following (not compile tested):

diff --git a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs
index 00ffbc1120..c4b85f087c 100644
--- a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs
+++ b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs
@@ -154,7 +154,10 @@ private void load(OsuColour colours, LocalisationManager localisation)
                             Text = TabletSettingsStrings.ConformToCurrentGameAspectRatio,
                             Action = () =>
                             {
-                                forceAspectRatio((float)host.Window.ClientSize.Width / host.Window.ClientSize.Height);
+                                float clientWidth = host.Window.ClientSize.Width;
+                                float clientHeight = host.Window.ClientSize.Height;
+
+                                forceAspectRatio((clientWidth * OutputAreaSize.X) / (clientHeight * OutputAreaSize.Y));
                             },
                             CanBeShown = { BindTarget = enabled }
                         },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't change tablet area to screen area mapping
2 participants